<script lang="jsx" setup>
import dayjs from 'dayjs';
import { computed, nextTick, ref } from 'vue';

const commonSearchRef = ref(null);
const tableRef = ref(null);
const searchParams = ref({
  moduleNo: null,
  lotId: null,
  pnlId: null,
  time: null
});

const searchFormList = [
  {
    type: 'input',
    key: 'subEqpId',
    label: '设备ID',
    span: 24,
    md: 12,
    lg: 10,
    xl: 8,
    xxl: 6,
    placeholder: '请输入设备ID',
    showTime: true
  },
  {
    type: 'input',
    key: 'lotNo',
    label: '批次号',
    span: 24,
    md: 12,
    lg: 10,
    xl: 8,
    xxl: 6,
    placeholder: '请输入批次号',
    showTime: true
  },
  {
    type: 'dateRangePicker',
    key: 'time',
    label: '日期',
    span: 24,
    md: 12,
    lg: 10,
    xl: 8,
    xxl: 6,
    showTime: true // 显示时分秒选择
  }
];

const searchData = computed(() => {
  const params = {
    ...searchParams.value
  };
  if (searchParams.value?.time?.[0]) {
    params.startTime = dayjs(searchParams.value.time[0]).format('YYYY-MM-DD');
    params.endTime = dayjs(searchParams.value.time[0]).format('YYYY-MM-DD');
  }
  delete params.time;
  return params;
});

// 表格数据
const column = [
  {
    key: 'dataIndex',
    dataIndex: 'dataIndex',
    title: '序号',
    fixed: 'left',
    width: 70,
    align: 'center',
    checked: true,
    ellipsis: true
  },
  {
    key: 'subEqpName',
    dataIndex: 'subEqpName',
    title: '设备名称',
    width: 130,
    align: 'center',
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'subEqpId',
    dataIndex: 'subEqpId',
    title: '设备ID',
    width: 100,
    align: 'center',
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'fullProdNo',
    dataIndex: 'fullProdNo',
    title: '生产型号',
    width: 170,
    align: 'center',
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'lotNo',
    dataIndex: 'lotNo',
    title: '批次号',
    width: 150,
    align: 'center',
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'dateTime',
    dataIndex: 'dateTime',
    title: ' 日期',
    width: 170,
    align: 'center',
    checked: true,
    ellipsis: true,
    fixed: 'left'
  },
  {
    key: 'upstreamExposureEnergy',
    dataIndex: 'upstreamExposureEnergy',
    title: '上流曝光能量',
    width: 150,
    align: 'center',
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamExposureEnergy',
    dataIndex: 'downstreamExposureEnergy',
    title: '下流曝光能量',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamShrinkageCoefficientX',
    dataIndex: 'upstreamShrinkageCoefficientX',
    title: '上流收缩系数X',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamShrinkageCoefficientX',
    dataIndex: 'downstreamShrinkageCoefficientX',
    title: '下流收缩系数X',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamShrinkageCoefficientY',
    dataIndex: 'upstreamShrinkageCoefficientY',
    title: '上流收缩系数Y',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamShrinkageCoefficientY',
    dataIndex: 'downstreamShrinkageCoefficientY',
    title: '下流收缩系数Y',
    align: 'center',
    width: 150,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe0',
    dataIndex: 'upstreamPe0',
    title: '上流PE0',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamPe0',
    dataIndex: 'downstreamPe0',
    title: '下流PE0',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe1',
    dataIndex: 'upstreamPe1',
    title: '上流PE1',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },

  {
    key: 'downstreamPe1',
    dataIndex: 'downstreamPe1',
    title: '下流PE1',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe2',
    dataIndex: 'upstreamPe2',
    title: '上流PE2',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamPe2',
    dataIndex: 'downstreamPe2',
    title: '下流PE2',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe3',
    dataIndex: 'upstreamPe3',
    title: '上流PE3',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamPe3',
    dataIndex: 'downstreamPe3',
    title: '下流PE3',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe4',
    dataIndex: 'upstreamPe4',
    title: '上流PE4',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamPe4',
    dataIndex: 'downstreamPe4',
    title: '下流PE4',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'upstreamPe5',
    dataIndex: 'upstreamPe5',
    title: '上流PE5',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  },
  {
    key: 'downstreamPe5',
    dataIndex: 'downstreamPe5',
    title: '下流PE5',
    align: 'center',
    width: 120,
    checked: true,
    ellipsis: true
  }
];

function search() {
  tableRef.value.getData(1);
}

function reset() {
  nextTick(() => {
    searchParams.value = {
      subEqpId: null,
      lotNo: null,
      time: null
    };
    search();
  });
}
</script>

<template>
  <div
    class="code-whitelist-page jl-main-page min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto"
  >
    <CommonSearch
      ref="commonSearchRef"
      v-model:searchParams="searchParams"
      :form-list="searchFormList"
      :is-search="true"
      @search="search"
      @reset="reset"
    ></CommonSearch>

    <Table
      ref="tableRef"
      v-model:searchParams="searchData"
      :column="column"
      :show-row-selection="false"
      :auto-generate-uuid="true"
      :scroll="{ y: 'auto' }"
      is-init-get-data
      url="eap/daZu/ldiParameterCollect/list"
    ></Table>
  </div>
</template>

<style lang="scss" scoped></style>
